<?php
/**
 * 公共控制器
 * Created		: 2012-05-30
 * Modified		: 2012-06-20
 * @link		: http://www.01pet.com
 * @copyright	: (C) 2011 01pet.com 
 * @version		: 1.0.0
 * @author		: Joseph Chen (chenliq@gmail.com)
 */
class Controller_Index extends Controller
{
	/**
	 * 构造函数，初始化操作
	 */
	public function __construct()
	{
	}
	
	/**
	 * (non-PHPdoc)
	 * @see Controller::index()
	 */
	public function index()
	{
		// 获取推荐
		$commentList = include APP_PATH.'data/videocache/comment.php';
		$commentIds = $commentList['ids'];
		unset($commentList['ids']);
		$this->commentList = $commentList;
		
// 		//获取新闻公告列表
// 		$mo = new Model_Article();
// 		$options = array(
// 			'order'			=> 'post_time desc',
// 			'limit'=> 30,
// 		);
// 		$this->newsList = $mo->getList($options);

		// 视频列表
		$v = new Model_Video();
		$params = array(
			'excludeIds'	=> $commentIds,
			'order'			=> 'post_time desc',
			'limit'			=> 30,
		);
		$this->videoList = $v->getList();
	}
	
	/**
	 * 注册页面
	 */
	public function signup()
	{
		header('Location:/index.php?co=member&do=signup');
		exit;
	}
	
	/**
	 * 登录页面
	 */
	public function login()
	{
		header('Location:/index.php?co=member&do=login');
		exit;
	}
	
	/**
	 * 生成验证码
	 */
	public function authcode()
	{
		if (empty($_GET['gif'])) {
			Tools::authcode();
		} else {
			Tools::gifAuthcode();
		}
	}
	
	/**
	 * 手动清空（输入链接）
	 */
	public function clearExpireOnlineData()
	{
		$expireTime = time() - $GLOBALS['_cookie_user_expire'];
		$sql = <<<eot
DELETE FROM user_online WHERE last_online_time<$expireTime;
OPTIMIZE TABLE user_online;
eot;
		echo Db::execute($sql);
		return false;
	}
}